package cn.com.generaldata.os.util;

import java.beans.BeanInfo;
import java.beans.PropertyDescriptor;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.lang.reflect.Method;
import java.util.HashMap;

public class ConverBean {
	public static HashMap<String,Method> converBean(Class<?>drbean){
		Class<?> stopClass=null;
		BeanInfo drbeaninfo=null;
		PropertyDescriptor[] props;
		HashMap<String,Method> map=new HashMap<String,Method>();
		try {
			drbeaninfo=Introspector.getBeanInfo(drbean,stopClass);
			props=drbeaninfo.getPropertyDescriptors();
			for(int i=0;i<props.length;i++)
			{
				Method setMethod=props[i].getWriteMethod();
				if(setMethod!=null)
				{
					String field=props[i].getName().toLowerCase();
					map.put(field, setMethod);
				}
			}
		} catch (IntrospectionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return map;
	}
}
